; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -passes="loop(indvars,loop-deletion,loop-unroll-full)" -verify-scev -S %s | FileCheck %s

define i32 @test(i32 %p_16, i1 %c) {
; CHECK-LABEL: @test(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[XOR:%.*]] = xor i32 [[P_16:%.*]], 6
; CHECK-NEXT:    [[OR_1:%.*]] = or i32 [[XOR]], [[P_16]]
; CHECK-NEXT:    [[XOR_1:%.*]] = xor i32 [[OR_1]], 6
; CHECK-NEXT:    [[OR_2:%.*]] = or i32 [[XOR_1]], [[P_16]]
; CHECK-NEXT:    [[XOR_2:%.*]] = xor i32 [[OR_2]], 6
; CHECK-NEXT:    br label [[OUTER_HEADER:%.*]]
; CHECK:       outer.header:
; CHECK-NEXT:    br label [[INNER_HEADER:%.*]]
; CHECK:       inner.header:
; CHECK-NEXT:    br i1 [[C:%.*]], label [[OUTER_LATCH:%.*]], label [[INNER_LATCH:%.*]]
; CHECK:       inner.latch:
; CHECK-NEXT:    br i1 [[C]], label [[OUTER_LATCH]], label [[INNER_LATCH_1:%.*]]
; CHECK:       inner.latch.1:
; CHECK-NEXT:    br i1 [[C]], label [[OUTER_LATCH]], label [[INNER_LATCH_2:%.*]]
; CHECK:       inner.latch.2:
; CHECK-NEXT:    br i1 [[C]], label [[OUTER_LATCH]], label [[INNER_LATCH_3:%.*]]
; CHECK:       inner.latch.3:
; CHECK-NEXT:    [[XOR_2_LCSSA:%.*]] = phi i32 [ [[XOR_2]], [[INNER_LATCH_2]] ]
; CHECK-NEXT:    [[OR_3:%.*]] = or i32 [[XOR_2_LCSSA]], [[P_16]]
; CHECK-NEXT:    [[XOR_3:%.*]] = xor i32 [[OR_3]], 6
; CHECK-NEXT:    ret i32 [[XOR_3]]
; CHECK:       outer.latch:
; CHECK-NEXT:    br label [[OUTER_HEADER]]
;
entry:
  br label %outer.header

outer.header:
  %p.1 = phi i32 [ 0, %entry ], [ %p.2.lcssa, %outer.latch ]
  br label %inner.header

inner.header:
  %p.2 = phi i32 [ %p.1, %outer.header ], [ %xor, %inner.latch]
  %p.3 = phi i32 [ 0, %outer.header ], [ %add, %inner.latch ]
  br i1 %c, label %outer.latch, label %inner.latch

inner.latch:
  %or = or i32 %p.2, %p_16
  %xor = xor i32 %or, 6
  %add = add nuw nsw i32 %p.3, 1
  %cmp = icmp ult i32 %p.3, 3
  br i1 %cmp, label %inner.header, label %exit

outer.latch:                                ; preds = %for.body2928
  %p.2.lcssa = phi i32 [ %p.2, %inner.header ]
  br label %outer.header

exit:
  %xor.lcssa = phi i32 [ %xor, %inner.latch ]
  ret i32 %xor.lcssa
}

